<!doctype html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Baidu Maps</title>
		<style>
			html { height: 100% }
			body { height: 100%; margin: 0; padding: 0; background-color: #FFF }
		</style>
		<script>
      var map, geocoder;

      function initialize() {  
        map = new BMap.Map('map_canvas'); 
        var point = new BMap.Point(121.491, 31.233);
        map.centerAndZoom(point, 11);  
        map.addControl(new BMap.NavigationControl());
        map.enableScrollWheelZoom();
        //获取定位
        var geolocation = new BMap.Geolocation();
        geolocation.getCurrentPosition(function(r){
          if(this.getStatus() == BMAP_STATUS_SUCCESS){
            var mk = new BMap.Marker(r.point);
            map.addOverlay(mk);
            map.panTo(r.point);
            map.setZoom(15);
          }
          else {
          }        
        });
      }  
   
      function loadScript() {  
        var script = document.createElement("script");  
        script.src = "https://api.map.baidu.com/api?v=2.0&ak=rGeQywxR5cAzRXXNTyZeeAY1o5Qsndp1&callback=initialize";
        document.body.appendChild(script);  
      }  

      function search(address) {
				if (!map) return;
				var local = new BMap.LocalSearch(map, {
					renderOptions: {
						map: map,
						autoViewport: true,
						selectFirstResult: false
					}
				});
				local.search(address);
      }


			
		</script>
	</head>
	<body onload="loadScript();">
		<div id="map_canvas" style="width:100%; height:100%"></div>
	</body>
</html>
